<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ContentPlaceHolderID="TitleContent" runat="server">
    <%=Html.PageTitle(FileLanguage.file_manager,"/") %>
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        <%=FileLanguage.file_manager %></h2>
    <%= Html.ValidationSummary(FileLanguage.error)%>
    <%  string path = (string)ViewData["dir"]; %>
    <table>
        <tr>
            <th class="rootfolder">
                <%=Html.MytripImageLink(Url.Action("Index",new{id=string.Empty}),
                "/Content/files/Stuffed_Folder.png", Membership.ApplicationName,0,32,0) %>
            </th>
            <th>
                <%= Html.ActionLink(Membership.ApplicationName, "Index", new { id = string.Empty })%>
                <%=Html.MytripDirectory(path)%>
            </th>
        </tr>
    </table>
    <table>
        <tr>
            <% using (Html.BeginForm("Create", "File", new { id = path }))
               {%>
            <th class="dableinput">
                <%=FileLanguage.create_new_folder %>
                <%= Html.TextBox("name")%>
                <%=Html.MytripInput("submit", FileLanguage.create) %>
            </th>
            <% } %>
            <% using (Html.BeginForm("Index", "File", FormMethod.Post,
                                new { enctype = "multipart/form-data" }))
               {%>
            <th class="oneinput">
                <%=FileLanguage.upload_file %>
                <%=Html.MytripInput("file",string.Empty,"file",string.Empty) %>
                <%=Html.MytripInput("submit", FileLanguage.upload) %>
            </th>
            <% } %>
        </tr>
    </table>
    <table>
        <tr>
            <th class="editdelite">
            </th>
            <th class="folderfile">
            </th>
            <th>
            </th>
            <th class="filechangedate">
                <%=FileLanguage.change_date  %>
            </th>
            <th class="filesize">
                <%=FileLanguage.size %>
            </th>
        </tr>
        <% foreach (System.IO.DirectoryInfo x in (IEnumerable)ViewData["folder"])
           {
               string url = path + "()" + x.Name;
        %>
        <tr>
            <td>
                <%=Html.MytripImageLink(Url.Action("Rename", "File", new { id = url, t = "folder" }),
                                                 "/Content/images/rename.png", FileLanguage.rename, 20, 0, 0)%>
                <%=Html.MytripImageLink(Url.Action("Delete", "File", new { id = url, t = "folder" }),
                                                 "/Content/images/delete.png", "delete", 20, 0, 0, FileLanguage.are_you_sure)%>
            </td>
            <td>
                <%=Html.MytripImageLink(Url.Action("Index", "File", new { id = url }),
                                            "/Content/files/Stuffed_Folder.png", x.Name, 0, 32, 0)%>
            </td>
            <td>
                <%=Html.MytripActionLink(Url.Action("Index", "File", new { id = url }), x.Name)%>
            </td>
            <td>
            </td>
            <td>
            </td>
        </tr>
        <%}
           foreach (System.IO.FileInfo x in (IEnumerable)ViewData["file"])
           {
               string url = (path + "/" + x.Name).Replace("()", "/");
               if (x.Extension != ".ico" && x.Extension != ".png" && x.Extension != ".jpg" && x.Extension != ".gif")
               { url = "/content/files/" + x.Extension + ".png"; }
               string _path = path + "()" + x.Name;%>
        <tr>
            <td>
                <%=Html.MytripImageLink(Url.Action("Rename", "File", new { id = _path, t = "file" }),
                                                 "/Content/images/rename.png", FileLanguage.rename, 20, 0, 0)%>
                <%=Html.MytripImageLink(Url.Action("Delete", "File", new { id = _path, t = "file" }),
                                                 "/Content/images/delete.png", "delete", 20, 0, 0, FileLanguage.are_you_sure)%>
            </td>
            <td>
                <%=Html.MytripImageLink(_path.Replace("()", "/"), url, x.Name, 0, 32, 0)%>
            </td>
            <td>
                <%=Html.MytripActionLink(_path.Replace("()", "/"), x.Name)%>
            </td>
            <td>
                <%=x.LastWriteTime %>
            </td>
            <td>
                <%=x.Length %>
                <%=FileLanguage.bytes%>
            </td>
        </tr>
        <%}%>
    </table>
</asp:Content>
